package com.penjin.android.activity.apply;

import android.os.Bundle;
import android.view.View;

import com.loopj.android.http.RequestParams;
import com.penjin.android.R;
import com.penjin.android.utils.DateUtil;
import com.penjin.android.utils.JsonUtils;
import com.penjin.android.utils.ToastHelper;
import com.penjin.android.view.TitleBarView;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by Administrator on 2016/4/5.
 */
public class BukaApplyDetailActivity extends BillApplyDetailActivity {

    @Override
    protected void onInitView() {
        this.titleBarView.setTitleBarListener(new TitleBarView.TitleBarListener() {
            @Override
            public void left(View view) {
                BukaApplyDetailActivity.this.finish();
            }

            @Override
            public void center(View view) {

            }

            @Override
            public void right(View view) {

            }
        });
        this.titleBarView.setCenterText("补签申请单");

        //修改显示区域内容
        timeName.setText("补签卡日期");
        findViewById(R.id.wrapper5).setVisibility(View.GONE);
        findViewById(R.id.wrapper6).setVisibility(View.GONE);
        findViewById(R.id.line2).setVisibility(View.GONE);
        findViewById(R.id.line3).setVisibility(View.GONE);
    }

    @Override
    protected void onInitData(Bundle bundle) {

    }

    @Override
    protected RequestParams generateParams() {
        RequestParams params = new RequestParams();
        params.put("staffNumber", staff.getStaffNumber());
        params.put("companyId", company.getCompanyId());
        params.put("billSort", billSort);
        params.put("id", id);
        params.put("billNumber", billNum);
        System.out.println("billNumber=" + billNum);
        return params;

    }

    @Override
    protected void onLoadBillDetailSuccess(String s) {
        try {
            JSONObject jo = new JSONObject(s);
            boolean result = jo.optBoolean("result");
            JSONArray dataArray = jo.getJSONArray("data");
            JSONObject data = dataArray.getJSONObject(0);
            if (result) {
                billNumber.setText(billNum);
                billTypeName.setText(data.optString("billType"));
                type.setText(data.optString("type"));
                String reason = data.optString("reason");
                if (JsonUtils.isJsonNull(reason)) {
                    detail.setText("详情未填写");
                } else
                    detail.setText(jo.optString("reason"));
                timeDays.setText(this.billDate);
            }
        } catch (Exception e) {
            e.printStackTrace();
            ToastHelper.showJsonError(this);
        }
    }

}
